package com.atfcm.hash;

import java.util.HashMap;

public class T_383_赎金信 {
    public boolean canConstruct(String ransomNote, String magazine) {
        HashMap<Character, Integer> map1 = new HashMap<>(ransomNote.length());

        for (int i = 0; i < magazine.length(); i++) {
            char c = magazine.charAt(i);
            map1.put(c, map1.getOrDefault(c, 0) + 1);
        }


        for (int i = 0; i < ransomNote.length(); i++) {
            char c = ransomNote.charAt(i);
            Integer num = map1.getOrDefault(c,0);

            num--;
            if(num <0){
                return false;
            }else {
                map1.put(c,num);
            }
        }
        return true;
    }

    public static void main(String[] args) {
        int[] ints = new int[26];
        for (int i = 0; i < ints.length; i++) {
            ints[i] = i;
        }
    }
}
